package com.yanqu.road.server.manger.activity.auto.send;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.UnionActivityConditionData;
import com.yanqu.road.entity.activity.UserActivityConditionData;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.entity.union.activitygroup.UnionActivityGroup;
import com.yanqu.road.logic.bussiness.player.UserActivityBussiness;
import com.yanqu.road.pb.rank.YRankProto;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.union.GameUnionActivityGroupMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class SonHaiActivityAutoSend extends BaseAutoSendActivity {

    public SonHaiActivityAutoSend(ActivityInfo activityInfo) {
        super(activityInfo);
    }

    @Override
    public void sendLocalUserRankReward() {

    }

    @Override
    public void sendLocalUnionRankReward() {

    }

    @Override
    protected boolean updateConditionData(UserActivityConditionData data) {
        return UserActivityBussiness.updateUserActivityConditionData(data);
    }

    @Override
    public void sendConditionReward() {

    }

    @Override
    public List<UserActivityConditionData> getNeedSendUserActivityConditionData() {
        return null;
    }

    @Override
    public Map<String, UnionActivityConditionData> getUnionActivityConditionData(int conditionType) {
        return UserActivityBussiness.getUnionActivityConditionDataMap(activityInfo.getActivityId(), conditionType);
    }

    @Override
    public Map<Long, UserActivityConditionData> getUserActivityRankConditionData(int activityId, int conditionType) {
        return getUserNormalActivityRankConditionData(activityId, conditionType);
    }

    @Override
    public void noticeCrossUserRank() {
        Map<Integer, UnionActivityGroup> groupMap = GameUnionActivityGroupMgr.getGroupMap(activityInfo.getActivityId());
        if (groupMap == null || groupMap.isEmpty()) {
            getLogger().error("山海伏兽-自动补发个人榜单奖励-获取商会分组失败：{}", activityInfo.getActivityId());
            return;
        }
        for (int groupId : groupMap.keySet()) {
            YRankProto.YRankReqMsg.Builder builder = YRankProto.YRankReqMsg.newBuilder();
            builder.setActivityId(activityInfo.getActivityId());
            builder.setGroupId(groupId);
            builder.setIdKey(String.valueOf(eGamePlayerEventType.SonHaiUserRank.getValue()));
            GamePlayerMgr.sendUnionActivityGroupPacket(CrossProtocol.C2_CROSS_YRANK_AUTO_SEND_USER_RANK, builder, 0, activityInfo.getActivityId(), groupId);
        }
    }
}
